package com.cpr.core.rabbitmq.springctl.anno;

import com.cpr.core.rabbitmq.springctl.anno.config.RabbitConsumerGetConfig;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author Chen Panrui
 * created at 2022/3/16 0:15
 */
public class ConsumerGetApp {
    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RabbitConsumerGetConfig.class);
        RabbitTemplate template = context.getBean(RabbitTemplate.class);

        Message message = template.receive("queue.anno");
        assert message != null;
        System.out.println(new String(message.getBody(), message.getMessageProperties().getContentEncoding()));
        context.close();
    }
}
